<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info">
            <form id="menu-form">
                <div class="select-list gd">
                    <ul>
                        <li>
                            菜单名称：<input type="text" name="perName"/>
                        </li>
                        <li>
                            菜单类型：<select name="type">
                            <option value="">所有</option>
                            <option value="1">目录</option>
                            <option value="2">菜单</option>
                            <option value="3">按钮</option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm"
                               onclick="$.treeTable.search('menu-form')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm"
                               onclick="$.form.reset($('form').attr('id'))"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group hidden-xs" id="toolbar" role="group">
            <a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add('0')"
               shiro:hasPermission="menu:add">
                <i class="fa fa-plus"></i> 新增
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = "/menu"
    var updateFlag = [[${@permission.hasPermi('menu:update')}]];
    var delFlag = [[${@permission.hasPermi('"menu:del')}]];
    $(function () {
        var options = {
            id: "permissionId",
            parentId: "parenId",
            expandAll: false,
            url: prefix + "/tableList",
            createUrl: prefix + "/toAdd/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/del",
            modalName: "菜单",
            columns: [{
                title: '菜单名称',
                field: 'perName',
                width: '20%',
                formatter: function (value, row, index) {
                    if ($.common.isEmpty(row.icon)) {
                        return row.perName;
                    } else {
                        return '<i class="' + row.icon + '"></i> <span class="nav-label">' + row.perName + '</span>';
                    }
                }
            },
                {
                    field: 'url',
                    title: '请求地址',
                    width: '15%',
                    align: "center"
                },
                {
                    title: '类型',
                    field: 'type',
                    width: '10%',
                    align: "center",
                    formatter: function (value, item, index) {
                        if (item.type == 1) {
                            return '<span class="label label-success">目录</span>';
                        }
                        else if (item.type == 2) {
                            return '<span class="label label-primary">菜单</span>';
                        }
                        else if (item.type == 3) {
                            return '<span class="label label-warning">按钮</span>';
                        }
                    }
                },

                {
                    field: 'code',
                    title: '权限标识',
                    width: '15%',
                    align: "center"
                },
                {
                    title: '操作',
                    width: '20%',
                    align: "center",
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="' + updateFlag + 'btn btn-success btn-xs" href="#" onclick="$.operate.edit(\'' + row.permissionId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a  class="' + delFlag + 'btn btn-danger btn-xs " href="#" onclick=" $.treeTable.remove(\'' + row.permissionId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.treeTable.init(options);
    });

</script>
</body>
</html>